// 库引入
import React, {Component} from 'react';
import {inject, observer} from 'mobx-react';
import classNames from 'classnames';
import {Icon} from 'antd';

// 样式引入
import styles from './item.module.less';

@observer
class Item extends Component {
  render() {
    return (
      <a className={classNames(styles.item, this.props.className)} style={this.props.style} href={this.props.to} target={this.props.to.indexOf('http') !== -1 ? '_blanck': '_self'}>
        <Icon className={styles.icon} type={this.props.iconType} /><span className={styles.text}>{this.props.value}</span>
      </a>
    );
  }
}

Item.defaultProps = {
  to: '',
  iconType: '',
  value: ''
};

const InjectItem = inject(({someStore={}}) => ({someProps: someStore.attribute}))(Item);

export {
  Item,
  InjectItem
};